<!--认款订单明细-->
<template>
  <div>
    <f-search-form ref='search' :more='true' @searchHandler='searchHandler'>
      <f-search-form-item label='订单编号' name='orderNo' style='width: 200px' />
      <f-search-form-item label='部门' name='deptId' type='select' :data='api.dept.list' value-key='deptId' label-key='deptName' @change='deptChange' style='width: 220px' :params='queryParam'/>
      <f-search-form-item ref='saleMan' label='业务员' name='saleManId' :show-all='false' type='select' style='width: 220px' :params='params1' :autoLoad='false' :data='api.saleMan.list' valueKey='saleManId' labelKey='saleManName' v-show='queryParam.deptId' />
      <f-search-form-item label='发货日期' type='range' name='beginDate' style='width: 310px' />
      <f-search-form-item label='回款日期' type='date' name='returnDate' style='width: 240px' slot='advanced' />
    </f-search-form>
    <f-table ref='table'
             rowKey='orderDetailsId'
             :showSetting='true'
             setting-key='settleTab1'
             :tableColumns='columns'
             :scroll='{x:true}'
             :showMultipleBtn='false'
             :showPagination='false'
             :showTotal='true'
             :multiple='false'
             handler='saleBalanceDiKouDetailsPageListHandler'
             :operator='operator'
             :autoLoad='false'
             :params='queryParam'
             :api='api.bsmb'>
       <span slot='drugType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text=="ZY"'>自营</a-tag>
            <a-tag color='#FF0000' v-if='text=="ZS"'>招商</a-tag>
        </span>
      <span slot='sendType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text==1'>现款</a-tag>
            <a-tag color='#FF0000' v-if='text==2'>预收款</a-tag>
            <a-tag color='#87d068' v-if='text==3'>资保金</a-tag>
            <a-tag color='purple' v-if='text==4'>全额资信</a-tag>
        </span>
      <span slot='action' slot-scope='text, record, index' v-if='record.orderDetailsId'>
       
      </span>
    </f-table>
   

  </div>
</template>
<script>
import api from "./../../js/api"



export default {
  name: "DikouDetails",
  components: {   },
  data() {
    let me = this
    //操作按钮
    let operator = []
    return {
      api: Object.assign(api, this.api),
      multiple: false,
      deptId: "",
      //列表初始化查询参数
      queryParam: {
        auth: 1,
        isFlp:1
      },
      returnCustomBond: 0,
      selectIds: "",
      params1: {
        deptId: ""
      },
      dataSource: [],
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "center",
          fixed: "left",
          dataIndex: 'rowIndex',
          customRender: function (text, record, index) {
            return (record.rowIndex !== '合计') ? (parseInt(index) + 1) : record.rowIndex
          }
        },
        {
          title: "订单编号",
          align: "center",
          width: "130px",
          fixed: "left",
          dataIndex: "orderNo"
        },
        {
          title: "单据日期",
          align: "center",
          width: "100px",
          dataIndex: "sendDate"
        },
        {
          title: "业务员",
          align: "center",
          width: "100px",
          dataIndex: "saleManName"
        },
        {
          title: "商品名称",
          align: "center",
          ellipsis: true,
          width: "140px",
          dataIndex: "drugsName"
        },
        {
          title: "规格",
          align: "center",
          width: "80px",
          dataIndex: "drugsSpec"
        },
        {
          title: "类型",
          align: "center",
          width: "80px",
          dataIndex: "drugType",
          scopedSlots: { customRender: "drugType" }
        },
        {
          title: "销售单价",
          align: "center",
          width: "80px",
          dataIndex: "salePrice"
        },
        {
          title: "数量",
          align: "center",
          width: "80px",
          dataIndex: "saleNum"
        },
        {
          title: "发货方式",
          align: "center",
          width: "100px",
          dataIndex: "sendType",
          scopedSlots: { customRender: "sendType" }
        },
        {
          title: "回款金额",
          align: "center",
          width: "80px",
          dataIndex: "returnAmount"
        },
        {
          title: "回款日期",
          align: "center",
          width: "120px",
          dataIndex: "returnDate"
        },
        {
          title: "资保金应收",
          align: "center",
          width: "90px",
          fixed: "right",
          dataIndex: "customBond"
        },
        {
          title: "资保金收款",
          align: "center",
          width: "90px",
          fixed: "right",
          dataIndex: "customBondTakeAmount"
        },
        {
          title: "收款日期",
          align: "center",
          width: "90px",
          fixed: "right",
          dataIndex: "customBondDate"
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {
    setData(data) {
      if (data && data.saleManBalanceId) {
        this.queryParam.saleManBalanceId = data.saleManBalanceId
        this.$refs["table"].refresh(false)
      }
    },
    //部门切换
    deptChange(value) {
      this.queryParam.deptId = value
      //this.openMultiple()
      this.$refs.saleMan.initData(this.queryParam)
      this.$refs.table.refresh(true, this.queryParam)
      this.$forceUpdate()
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    },

    /**
     * 刷新列表
     */
    onLoad() {
      this.$refs.table.refresh()
      this.$emit("changeTab")
    }
  }
}
</script>